package com.tang.excel.pa.mapper;

import com.tang.excel.pa.domain.EmQuestionCase;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Tang
 * @classname EmQuestionCaseMapper
 * @description [  ]
 * @date 2021/4/21 21:18
 */
public interface EmQuestionCaseMapper {

    int deleteByPrimaryKey(Integer id);

    @Insert(value = {
            "insert into em_question_case value ",
            "( null,#{topicId},#{caseId},#{testType.code},#{protocol.code},#{createTime} )"
    })
    int insert(EmQuestionCase record);

    int insertSelective(EmQuestionCase record);

    EmQuestionCase selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(EmQuestionCase record);

    int updateByPrimaryKey(EmQuestionCase record);

    @Results(id = "EmQuestionCase", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "topic_id", property = "topicId"),
            @Result(column = "options", property = "options"),
            @Result(column = "case_id", property = "caseId"),
            @Result(column = "create_time", property = "createTime")
    })
    @SelectProvider(type = EmQuestionCaseSqlProvider.class, method = "sqlByCondition")
    public List<EmQuestionCase> selectByCondition(EmQuestionCase emQuestionCase);

    @Insert(value = {
            "<script>",
            "insert into em_question_case (id,topic_id,case_id,test_type,protocol,create_time) values",
            "<foreach item = \"item\" collection = \"list\" separator = \",\">",
            "( null,#{item.topicId},#{item.caseId},",
            "#{item.testType.code},#{item.protocol.code},#{item.createTime} )",
            "</foreach>",
            "</script>"
    })
    int batchInsert(@Param("list") List<EmQuestionCase> list);
}